#!/bin/bash
#
# Run on each VM designated for Hadoop data node 
#
# 07/21/2012 - created by Trifon Anguelov

TMP_DIR=/tmp
HADOOP_DIR=/usr/local/hadoop
HADOOP_DATA_DIR=/data/hadoop


# update all packages
#sudo yum -y clean all
#sudo yum -y update

# install java
sudo yum -y install java-1.6.0-openjdk-devel.x86_64


# install hadoop
cd ~
wget http://www.globalish.com/am/hadoop/common/hadoop-1.0.3/hadoop-1.0.3.tar.gz
tar xvf hadoop-1.0.3.tar.gz
sudo mkdir ${HADOOP_DIR}
sudo cp -R hadoop-1.0.3/* ${HADOOP_DIR}
sudo chown -R 500:500 ${HADOOP_DIR}
sudo mkdir -p ${HADOOP_DATA_DIR}
sudo chown 500:500 ${HADOOP_DATA_DIR}


# setup hadoop
mkdir ${TMP_DIR}/hadoop
cd ${TMP_DIR}/hadoop
tar xvf ${TMP_DIR}/hadoop.tar
mv tmp/conf .
cp .bashrc ~

cd ${TMP_DIR}/hadoop/conf
cp * ${HADOOP_DIR}/conf


mkdir ${HADOOP_DIR}/examples
cd ${TMP_DIR}/hadoop/examples
cp * ${HADOOP_DIR}/examples/


# let's clean up
rm -rf ${TMP_DIR}/hadoop
cd ~
rm -f hadoop-1.0.3.tar.gz
rm -rf hadoop-1.0.3

exit
